package com.ydgk.service.impl;

import com.ydgk.bean.Kinds;
import com.ydgk.dao.FurnitureMapper;
import com.ydgk.dao.KindsMapper;
import com.ydgk.dao.KindsTypeMapper;
import com.ydgk.dao.Pre_orderMapper;
import com.ydgk.service.KindsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class KindsServiceImpl implements KindsService {

    @Autowired
    private KindsMapper kindsMapper;

    @Autowired
    private KindsTypeMapper kindsTypeMapper;

    @Autowired
    private FurnitureMapper furnitureMapper;


    public int insert(Kinds kinds) {
        return kindsMapper.insert(kinds);
    }

    public List<Kinds> findAll() {
        return kindsMapper.findAll();
    }

    public int deleteById(int kid) {
        int i = furnitureMapper.findCountByKid(kid);
        if(i > 0){
            return 0;
        }else{
            kindsTypeMapper.deleteByKid(kid);
            return kindsMapper.deleteById(kid);
        }
    }

    public Kinds findById(int kid) {
        return kindsMapper.findById(kid);
    }

    public int updateById(Kinds kinds) {
        return kindsMapper.updateById(kinds);
    }
}
